//  @ Project : GagalPanen
//  @ File Name : creature.cpp
//  @ Date : 3/9/2011
//  @ Author : Denis
//
//

#include <string>
#include "creature.hpp"
#include "gamemaps.hpp"

Creature::Creature(GameInterface* game, Cell* cell) :
    game_(game), cell_(cell) {
}

Creature::Creature(GameInterface* game, std::ifstream& is) :
    game_(game) {
  std::string buffer;
  is >> buffer;
  int x,y;
  is >> x >> y;
  cell_ = game->getMaps()->getMapFromRep(buffer)->getCellAt(x,y);
}

void Creature::save(std::ofstream& os) {
  os << game_->getMaps()->getRepFromMap(getMap()) << std::endl;
  os << getCell()->getX() << " " << getCell()->getY() << std::endl;
}

Creature::~Creature() {}

Cell* Creature::getCell() {
  return cell_;
}

GridMap* Creature::getMap() {
  return getCell()->getContainingMap();
}

